﻿namespace DailyPoetryX.Models {
    /// <summary>
    /// 诗词类。
    /// </summary>
    /// <remarks>
    /// 相较于DP，DPX的诗词类进行了很大的修改：
    /// 1. 更新到了sqlite-net。
    /// 2. 去除了大量没有使用过的属性。
    /// </remarks>
    /// <seealso cref="https://github.com/LauXy/DailyPoetry/blob/7dda74c82bd8314edcb2fb3040752d69a1be55a0/DailyPoetry/Models/KnowledgeModels/PoetryItem.cs"/>
    [SQLite.Table("works")]
    public class Poetry {
        /// <summary>
        /// 主键。
        /// </summary>
        [SQLite.Column("id")]
        public int Id { get; set; }

        /// <summary>
        /// 标题。
        /// </summary>
        [SQLite.Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 作者。
        /// </summary>
        [SQLite.Column("author_name")]
        public string AuthorName { get; set; }

        /// <summary>
        /// 朝代。
        /// </summary>
        [SQLite.Column("dynasty")]
        public string Dynasty { get; set; }

        /// <summary>
        /// 正文。
        /// </summary>
        [SQLite.Column("content")]
        public string Content { get; set; }

        /// <summary>
        /// 注释。
        /// </summary>
        [SQLite.Column("annotation")]
        public string Annotation { get; set; }

        /// <summary>
        /// 译文。
        /// </summary>
        [SQLite.Column("translation")]
        public string Translation { get; set; }

        /// <summary>
        /// 赏析。
        /// </summary>
        [SQLite.Column("appreciation")]
        public string Appreciation { get; set; }

        /// <summary>
        /// 显示布局。
        /// </summary>
        [SQLite.Column("layout")]
        public string Layout { get; set; }

        private string snippet;

        /// <summary>
        /// 预览。
        /// </summary>
        [SQLite.Ignore]
        public string Snippet =>
            snippet ?? (snippet = Content.Split('。')[0].Replace("\r\n", " "));

        /// <summary>
        /// 居中布局。
        /// </summary>
        public const string CENTER_LAYOUT = "center";

        /// <summary>
        /// 缩进布局。
        /// </summary>
        public const string INDENT_LAYOUT = "indent";
    }
}